package cn.edw.swu.bc.swucommunity

import android.util.Log
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.viewpager2.adapter.FragmentStateAdapter
import java.util.ArrayList

class MainLayoutAdapter(act: FragmentActivity): FragmentStateAdapter(act) {
    val fragments= arrayListOf<String>()
    override fun getItemCount(): Int {
        return fragments.size
    }
    override fun createFragment(pos: Int): Fragment {
        val item = getItem(pos)
        Log.d("@@create","创建fragement")
        return SessionFragment.newInstance()
    }
    fun setData(dataArray: ArrayList<String>) {
        fragments.addAll(dataArray)
        Log.d("@@setdata","输入数据")
        notifyDataSetChanged()
    }

    fun getItem(pos: Int): String {
        return fragments[pos]
    }
}